package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Courses5;
import com.ruoyi.system.service.ICourses5Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程表Controller
 * 
 * @author sunxu
 * @date 2025-02-14
 */
@RestController
@RequestMapping("/system/courses5")
public class Courses5Controller extends BaseController
{
    @Autowired
    private ICourses5Service courses5Service;

    /**
     * 查询课程表列表
     */
    @PreAuthorize("@ss.hasPermi('system:courses5:list')")
    @GetMapping("/list")
    public TableDataInfo list(Courses5 courses5)
    {
        startPage();
        List<Courses5> list = courses5Service.selectCourses5List(courses5);
        return getDataTable(list);
    }

    /**
     * 导出课程表列表
     */
    @PreAuthorize("@ss.hasPermi('system:courses5:export')")
    @Log(title = "课程表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Courses5 courses5)
    {
        List<Courses5> list = courses5Service.selectCourses5List(courses5);
        ExcelUtil<Courses5> util = new ExcelUtil<Courses5>(Courses5.class);
        util.exportExcel(response, list, "课程表数据");
    }

    /**
     * 获取课程表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:courses5:query')")
    @GetMapping(value = "/{courseId}")
    public AjaxResult getInfo(@PathVariable("courseId") Long courseId)
    {
        return success(courses5Service.selectCourses5ByCourseId(courseId));
    }

    /**
     * 新增课程表
     */
    @PreAuthorize("@ss.hasPermi('system:courses5:add')")
    @Log(title = "课程表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Courses5 courses5)
    {
        return toAjax(courses5Service.insertCourses5(courses5));
    }

    /**
     * 修改课程表
     */
    @PreAuthorize("@ss.hasPermi('system:courses5:edit')")
    @Log(title = "课程表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Courses5 courses5)
    {
        return toAjax(courses5Service.updateCourses5(courses5));
    }

    /**
     * 删除课程表
     */
    @PreAuthorize("@ss.hasPermi('system:courses5:remove')")
    @Log(title = "课程表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{courseIds}")
    public AjaxResult remove(@PathVariable Long[] courseIds)
    {
        return toAjax(courses5Service.deleteCourses5ByCourseIds(courseIds));
    }
}
